#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@File ：PointsController.py
@Author ：zqy
@Email : zqingy@work@163.com 
@note: 积分
"""

from flask_restx import Namespace, Resource

from application.model.UserModel import UserPoints
from application.util.ResponseUtil import ResponseUtil

points_ns = Namespace('points', description='积分模块')


@points_ns.route('/<int:user_id>')
class Points(Resource):
    def get(self, user_id):
        points = UserPoints.query.filter_by(user_id=user_id).first()
        if not points:
            data = {'points': 0}
        data = {'points': points.points_integer}
        return ResponseUtil(data=data).success()
